package org.rslai.util.process;

/**
 * Process 工厂
 * @author rslai
 */
public class ProcessFactory {
	private static ProcessFactory instance = new ProcessFactory();
	private static Process process;
	
	/**
	 * 返回一个 ProcessFactory 实例
	 * @return ProcessFactory 实例
	 */
	public static ProcessFactory getInstance() {
		return instance;
	}

	/**
	 * 返回一个 Process 实例
	 * @return Process 实例
	 */
	public static Process getProcess() {
		return process;
	}

	/**
	 * 私有化构造函数
	 */
	private ProcessFactory() {
		String osName = org.rslai.util.env.EnvVariable.getInstance().getOsName();
		if (osName.indexOf("Windows") != -1) {
			process = new ProcessWindows();
		} else if (osName.indexOf("Linux") != -1) {
			process = new ProcessLinux();
		} else {
			throw new IllegalArgumentException("未找到 " + osName + " 操作系统的 Process 实例！");
		}
	}
}
